package com.dragon.repository.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.AttendanceLeave;
import com.dragon.repository.entity.OtherFile;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AttendanceLeaveDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "请假id")
    private Integer id;

    @ApiModelProperty(value = "请假类型：1事假 2病假 3年假 4调休 5婚假 6丧假 7 产假")
    private Integer leaveType;

    @ApiModelProperty(value = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date endTime;

    @ApiModelProperty(value = "原因")
    private String cause;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "考勤主表id")
    private Integer attendanceId;

    @ApiModelProperty(value = "状态：0 待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "时长")
    private String duration;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "审核人名称")
    private String toUsername;

    @ApiModelProperty(value = "创建人名称")
    private String username;

    @ApiModelProperty(value = "创建人头像")
    private String userImg;

    @ApiModelProperty(value = "请假类型名称")
    private String leaveTypeName;

    @ApiModelProperty(value = "附件")
    private List<OtherFile> otherFiles;

    @ApiModelProperty(value = "工作流json")
    private List<WorkflowJson> workflowJsonList;

    public AttendanceLeaveDTO() {}

    public AttendanceLeaveDTO(AttendanceLeave entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static AttendanceLeaveDTO convert(AttendanceLeave entity) {
        return new AttendanceLeaveDTO(entity);
    }

    public static List<AttendanceLeaveDTO> convertList(List<AttendanceLeave> list) {
        List<AttendanceLeaveDTO> resultList = new ArrayList<>();
        for (AttendanceLeave entity : list) {
            resultList.add(new AttendanceLeaveDTO(entity));
        }
        return resultList;
    }}
